package com.itheima.consumer.feign;

import com.itheima.consumer.domain.Goods;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * feign声明式接口.发起远程调用的
 * String url = "http://FEIGN-PROVIDER/goods/findOne/"+id;
 * Goods goods = restTemplate.getForObject(url, Goods.class);
 * <p>
 * 1.定义接口
 * 2.接口上添加注解@FeignClient  设置value属性值为服务提供方的应用名
 * 3.编写调用接口,接口的声明规则和提供方接口保持一致
 * 4.注入该接口对象,调用接口方法完成远程调用
 */
@FeignClient(value = "feign-provider")
public interface GoodsFeignClient {

    @GetMapping("/goods/findOne/{id}")
    Goods findGoodsById(@PathVariable("id") int id);

}
